import axios from '@/utils/axios';

const state = {};
const mutations = {
  SET_USER_INFO: (state: any, userInfo: any) => {},
};
const actions = {
    // 获取网站列表
  async querySiteList({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_site/query_list',
      method: 'get',
      params,
    });
    return data;
  },
  // 开启采集任务
  async startTask({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_task/add',
      method: 'post',
      data: params,
    });
    return data;
  },
  // 获取采集数据列表
  async queryDataList({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_data/query_list',
      method: 'get',
      params,
    });
    return data;
  },
  // 获取采集爬虫
  async querySiteSpider({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_site/query_spider',
      method: 'get',
      params,
    });
    return data;
  },
  // 获取实时采集数据
  async queryCrawlingList({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_data/query_crawling_list',
      method: 'get',
      params,
    });
    return data;
  },
  // 获取正在采集数据
  async crawlTaskConsume({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_task/consume',
      method: 'post',
      data: params,
    });
    return data;
  },
  // 生成报告
  async crawlTaskConfirmDone({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_site/confirm_done',
      method: 'post',
      data: params,
    });
    return data;
  },
  // 获取任务状态
  async crawlAnalysisQuery({}, params: any) {
    const { data } = await axios({
      url: '/api/crawl_analysis/query',
      method: 'get',
      params,
    });
    return data;
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
